package com.qf.dao;

import com.qf.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserDao {

    @Insert("INSERT INTO `t_users`(`name`,`password`,`sex`,`birthday`,`registTime`) VALUES (#{name},#{password},#{sex},#{birthday},#{registTime});")
    @SelectKey(keyColumn = "id",keyProperty = "id",resultType = int.class,before = false,statement = "SELECT LAST_INSERT_ID()")
    int addUser(User user);

    @Delete("DELETE FROM `t_users` WHERE `id`=#{id}")
    int deleteUser(int id);

    @Select("SELECT * FROM `t_users` WHERE `id`=#{id}")
    User selectById(int id);

    @Update("UPDATE `t_users` SET `name`=#{name},`password`=#{password},`sex`=#{sex} WHERE `id`=#{id};")
    void updateUser(User user);

    @Select("SELECT * FROM `t_users`")
    List<User> selectAll();

}
